package mao.thinkinjava.interupt;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author Totoro
 * @date 2020/5/11 20:00
 */
public class IOBlocking implements Runnable {
    private InputStream in;
    public IOBlocking(InputStream in){
        this.in = in;
    }
    @Override
    public void run() {
        try {
            System.out.println("before read");
            in.read();
        } catch (IOException e) {
            if(Thread.currentThread().isInterrupted()){
                System.out.println("interrupt in blocking io");
            }else{
                throw new RuntimeException(e);
            }
        }
        System.out.println("thread quits");
    }
}
